# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=hqlmap
pkgver=38.bb6ab46
pkgrel=6
pkgdesc='A tool to exploit HQL Injections.'
arch=('any')
groups=('blackarch' 'blackarch-exploitation')
url='https://github.com/PaulSec/HQLmap'
license=('MIT')
depends=('python2' 'python2-simplejson' 'python2-beautifulsoup4'
         'python2-requests')
makedepends=('git')
source=("$pkgname::git+https://github.com/PaulSec/HQLmap.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -m 644 HQLmap.py "$pkgdir/usr/share/$pkgname/$pkgname.py"
  install -Dm 655 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a db "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

